<%@page language="java" pageEncoding="UTF-8"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt"%>
<%@taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<html>
	<head>
		<TITLE>权限管理--用户列表</TITLE>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<style type="text/css" media="all">
			@import "./jsp/manage/css/list.css";
			@import "./jsp/manage/css/ymPrompt.css";
			@import "./jsp/manage/thickbox-code/thickbox.css";
		</style>
		<script src="./jsp/manage/js/mon.js" type="text/javascript"></script>
		<script src="./jsp/manage/js/global.js" type="text/javascript"></script>
		<script src="./jsp/manage/js/thickbox.js" type="text/javascript"></script>
		<script src="./jsp/manage/js/ymPrompt.js" type="text/javascript"></script>
		<script src="./jsp/manage/js/jquery-compressed.js" type="text/javascript"></script>
		<script language="javascript" type="text/javascript">
		function fnOnPageChanged(page) {
			var keyword=document.getElementById("keyword").value;
			var keywordType=document.getElementById("keywordType").value;
			var selectedoption=document.getElementById("selectedoption");
			alert(selectedoption);
			var value=selectedoption.value
			alert(value);
			var url = '<%=request.getContextPath()%>/quanxianManage.do?method=userlist&keyword='+keyword+'&keywordType='+keywordType+'&selectedoption='+selectedoption+'&pageNow='+page;
			document.location.href = url;
		}
		</script>
	</head>
	<body>
		<div id="content">
			<TABLE class=border cellSpacing=1 cellPadding=2 width="100%" align=center border=0>
				<TBODY>
					<TR class=topbg>
						<TD align=middle colSpan=2 height=22>
							<STRONG>权限管理</STRONG>
						</TD>
					</TR>
					<TR class=topbg>
						<TD align=left colSpan=2 height=22>
							<STRONG>权限管理 [</STRONG>
							<span class="STYLE1"><a href="<%=request.getContextPath()%>/quanxianManage.do?method=userlist">用户列表</a>]</span>
							<span class="STYLE1">[<a href="<%=request.getContextPath()%>/quanxianManage.do?method=useradd">添加新用户</a>]</span></TD>
					</TR>
					<TR>
						<form name=form action="<%=request.getContextPath()%>/quanxianManage.do?method=userlist" method=post>
						<TD>
							<INPUT onclick=submit(); type=radio CHECKED id="all"  value=""
								name=radiooption <c:if test="${radiooption=='all'}" > checked</c:if>>
							ALL
							<INPUT onclick=submit(); type=radio id="weishenhe"  value=weishenhe
								name=radiooption <c:if test="${radiooption=='weishenhe'}" > checked</c:if>>
							未审核
							<INPUT onclick=submit(); type=radio id="yitongguo"  value=yitongguo
								name=radiooption <c:if test="${radiooption=='yitongguo'}" > checked</c:if>>
							已通过
							<INPUT onclick=submit(); type=radio id="weitongguo"  value=weitongguo
								name=radiooption <c:if test="${radiooption=='weitongguo'}" > checked</c:if>>
							未通过
							<br>
							用户组：
							<select name="selectedoption" onChange=submit();>
								<option value="null" selected>
									请选择
								</option>
								<logic:iterate id="w" name="group_arraylist"
									indexId="count">
									<option id="${w[0]}" name="${w[0]}" value="${w[0]}">
										${w[1]}
									</option>
								</logic:iterate>
							</select>
						</TD>
						</form>
					</TR>
				</TBODY>
			</TABLE>

				<table border="0" width="100%" align="center">
					<tr>
						<td align="center">
							<form action="<%=request.getContextPath()%>/quanxianManage.do?method=userlist&Action=Manage" method="post">
								<SELECT size=1 name=keywordType>
									<OPTION value="username" selected>
										登录用户名
									</OPTION>
									<OPTION value="name">
										姓名
									</OPTION>
								</SELECT>
								<input name="keyword" type="text" size="40" maxlength="40" />
								<input name="button" type="submit" value="查找" />
							</form>
						</td>
					</tr>
				</table>
				<form name="form_1" method="post">
					<table width="100%" border="0" cellspacing="0" cellpadding="0" class="data">
						<tr>
							<sec:authorize ifAllGranted="ROLE_QUANXIAN_SHENHE">
							<th colspan="2" align="center" nowrap="nowrap">
							</sec:authorize>
							<sec:authorize ifNotGranted="ROLE_QUANXIAN_SHENHE">
							<th colspan="1" align="center" nowrap="nowrap">
							</sec:authorize>
								<div align="center">编号</div>
							</th>
							<th width="10%" align="center" nowrap="nowrap">登录ID</th>
							<th width="15%" align="center" nowrap="nowrap">姓名</th>
							<th  width="20%"  align="center" nowrap="nowrap">Email</th>
							<th  width="20%"  align="center" nowrap="nowrap">所在部门</th>
							<th  width="20%"  align="center" nowrap="nowrap">所属用户组</th>
				            <th width="10%" align="center" nowrap="nowrap">审核状态</th>
			              <th width="10%" align="center" nowrap="nowrap">操作</th>
						</tr>
						<c:forEach items="${uglist}" var="vo">
							<c:if test="${vo.user.id%2==1}">
								<c:set var="rowtype" value="odd" />
							</c:if>
							<c:if test="${vo.user.id%2==0}">
								<c:set var="rowtype" value="even" />
							</c:if>
							<tr class="${rowtype}" onMouseOver="this.className = 'row_over';"
								onMouseOut="this.className = '${rowtype}';" >
								<sec:authorize ifAllGranted="ROLE_QUANXIAN_SHENHE">
								<td width="4%" align="center" nowrap="nowrap">
									<input type="checkbox" name="checkbox_${vo.user.id}"
										id="checkbox_row_${vo.user.id}"
										value="${vo.user.id}" />
								</td>
								</sec:authorize>
								<td width="7%" align="center" nowrap="nowrap">${vo.user.id}</td>
								<td align="center" nowrap="nowrap">
								<font color="red">
								<c:choose>
									<c:when test="${vo.user.status==1}"></c:when>
								</c:choose>
								</font>${vo.user.username}</td>
								<td align="center" nowrap="nowrap">${vo.user.name}</td>
								<td align="center" nowrap="nowrap">${vo.user.email}</td>
								<td align="center" nowrap="nowrap">${vo.user.department}</td>
								<td align="center" nowrap="nowrap">${vo.groups.groupName}</td>
								<td align="center" nowrap="nowrap">
								<c:choose>
								<c:when test="${vo.user.status==1}"><img src="./jsp/manage/images/ok.gif" width="13" height="13"></c:when>
								<c:when test="${vo.user.status==0}"><img src="./jsp/manage/images/aprove.gif" width="16" height="16"></c:when>
								<c:when test="${vo.user.status==2}"><img src="./jsp/manage/images/not.gif" width="16" height="16"></c:when>
								</c:choose>
								</td>
								<td align="center" nowrap="nowrap">
									 <a href="<%=request.getContextPath()%>/quanxianManage.do?method=useredit&id=${vo.user.id}&username=${vo.user.username}">编辑</a> 
									|
									<a href="<%=request.getContextPath()%>/quanxianManage.do?method=userdel&id=${vo.user.id}&username=${vo.user.username}"
										onClick="return confirm('您确定要删除 ${vo.user.username} 的账户吗？');">删除</a>	
								</td>
                          </tr>
						</c:forEach>
						<sec:authorize ifAllGranted="ROLE_QUANXIAN_SHENHE">
						<tr>
							<td colspan="2" align="center" bgcolor="#FCFCFC">
								&nbsp;
							</td>
							<td colspan="2" align="center" bgcolor="#FCFCFC">
								<input name="chkall" onClick="checkall(this.form)"
									type="checkbox">
								全选
							</td>
							<td width="6%" align="center" bgcolor="#FCFCFC">
								<input type="button" name="approved" id="approved1" value="审核通过"
									onClick="ymPrompt.confirmInfo('确认审核通过吗？',null,null,null,handler)" />
							</td>
							<td width="1%" align="center" bgcolor="#FCFCFC">
								&nbsp;
							</td>
							<td width="5%" align="center" bgcolor="#FCFCFC">
								<div align="left">
									<input type="button" name="notapproved" id="approved2"
										value="不通过"
										onClick="ymPrompt.confirmInfo('确认不通过吗？',null,null,null,handler2)" />
								</div>
							</td>
						</tr>
						</sec:authorize>
						<tr>
							<td colspan="17" align="center" bgcolor="#FCFCFC">
								<input type="hidden" id="keywordType" value="${keywordType}">
								<input type="hidden" id="keyword" value="${keyword}">
								<input type="hidden" id="selectedoption" value="${selectedoption}">								<div align="left">
									<span style="font-size: 13px">共<b>${entryTatal}</b>
										条记录&nbsp;&nbsp; <a
										href="<%=request.getContextPath()%>/quanxianManage.do?method=userlist&keyword=${keyword}&keywordType=${keywordType}&selectedoption=${selectedoption}&pageNow=1">首页
									</a> <c:choose>
											<c:when test="${pageNow>1}">
												<a
													href="<%=request.getContextPath()%>/quanxianManage.do?method=userlist&keyword=${keyword}&keywordType=${keywordType}&selectedoption=${selectedoption}&pageNow=${pageNow-1}">上一页</a>											</c:when>
											<c:otherwise> 上一页 </c:otherwise>
										</c:choose> <c:choose>
											<c:when test="${pageNow<pageTatal}">
												<a
													href="<%=request.getContextPath()%>/quanxianManage.do?method=userlist&keyword=${keyword}&keywordType=${keywordType}&selectedoption=${selectedoption}&pageNow=${pageNow+1}">下一页</a>											</c:when>
											<c:otherwise> 下一页 </c:otherwise>
										</c:choose> <a
										href="<%=request.getContextPath()%>/quanxianManage.do?method=userlist&keyword=${keyword}&keywordType=${keywordType}&selectedoption=${selectedoption}&pageNow=${pageTatal}">尾页</a>
										页次：<strong><font color="red">${pageNow}</font>/${pageTatal}</strong>页
										&nbsp;共<b>${entryTatal}</b>条记录 共 <b>${pageTatal}</b>
										页&nbsp;&nbsp;转到第 <select name="pagejump"
											onChange="fnOnPageChanged(this.value);">
											<c:forEach begin="1" end="${pageTatal}" var="i" step="1">
												<c:if test="${pageNow==i}">
													<option value="${i}" selected>
														&nbsp;&nbsp;${pageNow}&nbsp;&nbsp;
													</option>
												</c:if>
												<c:if test="${pageNow!=i}">
													<option value="<c:out value="${i}"/>">
														&nbsp;&nbsp;
														<c:out value="${i}" />
														&nbsp;&nbsp;
													</option>
												</c:if>
											</c:forEach>
										</select> 页</span>								
								</div>
							</td>
						</tr>
					</table>
					<table width="100%" border="0" cellpadding="2" cellspacing="0">
						<tr>
							<td>&nbsp;
							</td>
						</tr>
					</table>
				</form>
			</div>
	</body>
</html>
<script type="text/javascript">
function handler(tp){
if(tp=='ok'){
   document.form_1.action="<%=request.getContextPath()%>/quanxianManage.do?method=userApprove&approveState=1"
   document.form_1.submit(); 
}
if(tp=='cancel'){}
if(tp=='close'){}
}

function handler2(tp){
if(tp=='ok'){
   document.form_1.action="<%=request.getContextPath()%>/quanxianManage.do?method=userApprove&approveState=2";
   document.form_1.submit(); 
}
if(tp=='cancel'){}
if(tp=='close'){}
}
</script>
<script language="javascript" type="text/javascript">
	var selectedoption=document.getElementById("selectedoption").value;
	if(selectedoption!=""){
		document.getElementById(selectedoption).selected=true
	}
</script>